{% extends 'bootstrap-modal-layout.html.twig' %}
{% do script(['app/js/classroom-manage/course-detail/learn-modal/index.js'])%}
{% set modalSize = 'large' %}

{% block title %}
  {{'classroom.manage.data_statistics.course_detail.learn_conditions_detail'|trans({'%courseSetTitle%':course.courseSetTitle})|raw}}
{% endblock %}
{% block body %}
  <div class="js-course-learn-data">
    <form class="js-course-learn-detail" id="overview-course-learn-list">
      <input type="hidden" name="classroomId" value="{{ classroom.id }}">
      <input type="hidden" name="courseId" value="{{ course.id }}">
      <select style="width:200px;margin-right:15px" class="form-control pull-left" name="filter" tabindex="-1" id="status-select">
        <option value="all" {% if app.request.get('filter')|default('all') == 'all' %} selected {% endif %}
                data-url="{{ path('classroom_data_statistics_course_detail_modal', {id:classroom.id, courseId: course.id, filter: 'all'}) }}">{{ '全部' }}</option>
        <option value="unLearn" {% if app.request.get('filter')|default('all') == 'unLearn' %} selected {% endif %}
                data-url="{{ path('classroom_data_statistics_course_detail_modal', {id:classroom.id, courseId: course.id, filter: 'unLearn'}) }}">{{ '未学' }}</option>
        <option value="learning" {% if app.request.get('filter')|default('all') == 'learning' %} selected {% endif %}
                data-url="{{ path('classroom_data_statistics_course_detail_modal', {id:classroom.id, courseId: course.id, filter: 'learning'}) }}">{{ '学习中' }}</option>
        <option value="learned" {% if app.request.get('filter')|default('all') == 'learned' %} selected {% endif %}
                data-url="{{ path('classroom_data_statistics_course_detail_modal', {id:classroom.id, courseId: course.id, filter: 'learned'}) }}">{{ '已学完' }}</option>
      </select>
    </form>

    {% include 'export/export-btn.html.twig' with
      {
        'exportFileName' : 'classroom-statistics-course-learn-detail',
        'targetFormId': 'overview-course-learn-list',
        'exportClass': 'cd-btn-sm pull-right cd-btn-primary',
        'exportWebpack': 'ture',
        'customFileName': course.courseSetTitle
      }
    %}
    <table class="table table-striped table-hover">
      <thead>
      <tr>
        <th>{{'classroom.manage.data_statistics.header.user'|trans}}</th>
        <th>{{'classroom.manage.data_statistics.header.learn_conditions'|trans}}</th>
        <th>{{'classroom.manage.data_statistics.header.learn_progress'|trans}}</th>
        <th>{{'classroom.manage.data_statistics.header.finished_time'|trans}}</th>
      </tr>
      </thead>
      <tbody>
      {% for member in members %}
        {% set user = users[member.userId]|default([]) %}
        <tr>
          <td>{{ user.nickname|default('--') }} <span class="text-muted">{% if member.remark %}({{ member.remark|trans }}){% endif %}</span> </td>
          <td>
            {% if member.learnStatus == 'unLearn' %}
              <span class="cd-text-gray">{{ 'classroom.manage.data_statistics.finish_status.unlearn'|trans }}</span>
            {% elseif member.learnStatus == 'learning' %}
              <span class="cd-text-warning">{{ 'classroom.manage.data_statistics.finish_status.learning'|trans }}</span>
            {% elseif member.learnStatus == 'learned' %}
              <span class="cd-text-success">{{ 'classroom.manage.data_statistics.finish_status.learned'|trans }}</span>
            {% endif %}
          </td>
          <td>{{ member.finishRate }}%</td>
          <td>
            {% if member.isLearned %}
              {{ member.finishedTime|date('Y-m-d H:i:s') }}
            {% else %}
              {{ '--' }}
            {% endif %}
          </td>
        </tr>
      {% else %}
        <tr class="empty">
          <td colspan="20">{{'site.datagrid.empty'|trans}}</td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
    {{ web_macro.ajax_paginator(paginator) }}
  </div>
{% endblock %}
